webpackJsonp([53],{

/***/ "H7Q2":
/***/ (function(module, exports) {

// removed by extract-text-webpack-plugin

/***/ }),

/***/ "Qnwt":
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });

// EXTERNAL MODULE: ./node_modules/_babel-runtime@6.26.0@babel-runtime/regenerator/index.js
var regenerator = __webpack_require__("lC5x");
var regenerator_default = /*#__PURE__*/__webpack_require__.n(regenerator);

// EXTERNAL MODULE: ./node_modules/_babel-runtime@6.26.0@babel-runtime/helpers/asyncToGenerator.js
var asyncToGenerator = __webpack_require__("J0Oq");
var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator);

// EXTERNAL MODULE: ./node_modules/_babel-runtime@6.26.0@babel-runtime/core-js/object/values.js
var values = __webpack_require__("MgeX");
var values_default = /*#__PURE__*/__webpack_require__.n(values);

// EXTERNAL MODULE: ./src/common/api/commonApi.js
var commonApi = __webpack_require__("+/+p");

// EXTERNAL MODULE: ./src/common/plugin/index.js + 207 modules
var common_plugin = __webpack_require__("Tvds");

// CONCATENATED MODULE: ./node_modules/_babel-loader@7.1.5@babel-loader/lib!./node_modules/_vue-loader@13.7.3@vue-loader/lib/selector.js?type=script&index=0!./src/common/anjian/law/recordContent.vue



//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//




/* harmony default export */ var recordContent = ({
  data: function data() {
    return {
      form: {},
      list: [],
      url: __webpack_require__("Xdkc"),
      play: false,
      show: false
    };
  },

  computed: {
    disabled: function disabled() {
      var val = values_default()(this.form);
      val = val.filter(function (v) {
        return v;
      });
      return !(val && val.length);
    },
    active: function active() {
      return !!this.list.length;
    },
    getClass: function getClass() {
      return this.play ? 'is-play' : this.active ? 'is-active' : 'is-default';
    }
  },
  activated: function activated() {
    this.getContentId();
    this.fetchRecord();
  },

  methods: {
    getScoreInstance: function getScoreInstance(score, id) {
      var _$route$query = this.$route.query,
          record = _$route$query.record,
          enterprise = _$route$query.enterprise;

      var obj = {
        id: id,
        content_id: commonApi["a" /* commonApi */].createInstance('evaluation_content', this.contentId),
        ent_id: commonApi["a" /* commonApi */].createInstance('ent_enterprise', enterprise),
        sys_score_desc: '',
        sys_score: 0,
        score_time: Object(common_plugin["e" /* formatTime */])(new Date()),
        gov_score: parseFloat(score),
        gov_score_desc: '',
        total_score: parseFloat(score),
        collection_id: record,
        collection_name: 'law_record_danger'
      };
      return commonApi["a" /* commonApi */].createInstance('evaluation_result', obj);
    },
    onSave: function onSave(loaded) {
      var _this = this;

      return asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee() {
        var _$route$query2, record, enterprise, objects;

        return regenerator_default.a.wrap(function _callee$(_context) {
          while (1) {
            switch (_context.prev = _context.next) {
              case 0:
                _context.prev = 0;
                _$route$query2 = _this.$route.query, record = _$route$query2.record, enterprise = _$route$query2.enterprise;
                objects = _this.list.map(function (item) {
                  return commonApi["a" /* commonApi */].createInstance('law_record_danger', {
                    record_id: commonApi["a" /* commonApi */].createInstance('law_record', record),
                    ent_id: commonApi["a" /* commonApi */].createInstance('ent_enterprise', enterprise),
                    id: item.id,
                    danger_desc: item.desc,
                    score: _this.getScoreInstance(item.score, item.scoreId)
                  });
                });
                _context.next = 5;
                return commonApi["a" /* commonApi */].saveAll(objects);

              case 5:
                _this.$Toast('保存成功!', 'success');
                _this.$router.$back();
                _context.next = 12;
                break;

              case 9:
                _context.prev = 9;
                _context.t0 = _context['catch'](0);

                _this.$Toast('保存失败!', 'error');

              case 12:
                loaded();

              case 13:
              case 'end':
                return _context.stop();
            }
          }
        }, _callee, _this, [[0, 9]]);
      }))();
    },
    onRemove: function onRemove(index) {
      this.list.splice(index, 1);
      if (this.list.length === 0) {
        this.show = false;
      }
    },
    onClear: function onClear() {
      this.list = [];
      this.show = false;
    },
    doShow: function doShow() {
      this.show = true;
    },
    doEnd: function doEnd() {
      this.play = false;
    },
    doAdd: function doAdd(e) {
      this.play = true;
      this.$refs.cart.start(e.target);
      this.list.push(this.form);
      this.form = {};
    },
    getContentId: function getContentId() {
      var _this2 = this;

      return asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee2() {
        var res;
        return regenerator_default.a.wrap(function _callee2$(_context2) {
          while (1) {
            switch (_context2.prev = _context2.next) {
              case 0:
                _context2.next = 2;
                return commonApi["a" /* commonApi */].searchFirst('evaluation_content', {
                  equalTo: { assessment_encoding: 'D0010' }
                });

              case 2:
                res = _context2.sent;

                _this2.contentId = res ? res.id : null;

              case 4:
              case 'end':
                return _context2.stop();
            }
          }
        }, _callee2, _this2);
      }))();
    },
    fetchRecord: function fetchRecord() {
      var _this3 = this;

      return asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee3() {
        var record, records;
        return regenerator_default.a.wrap(function _callee3$(_context3) {
          while (1) {
            switch (_context3.prev = _context3.next) {
              case 0:
                record = _this3.$route.query.record;
                _context3.next = 3;
                return commonApi["a" /* commonApi */].search('law_record_danger', {
                  equalTo: { record_id: record },
                  include: ['score']
                });

              case 3:
                records = _context3.sent;

                _this3.list = records.map(function (item) {
                  return {
                    id: item.id,
                    desc: item.danger_desc,
                    score: item.score.attributes.gov_score,
                    scoreId: item.score.id
                  };
                });

              case 5:
              case 'end':
                return _context3.stop();
            }
          }
        }, _callee3, _this3);
      }))();
    }
  }
});
// CONCATENATED MODULE: ./node_modules/_vue-loader@13.7.3@vue-loader/lib/template-compiler?{"id":"data-v-2fe958fe","hasScoped":true,"transformToRequire":{"video":["src","poster"],"source":"src","img":"src","image":"xlink:href"},"buble":{"transforms":{}}}!./node_modules/_vue-loader@13.7.3@vue-loader/lib/selector.js?type=template&index=0!./src/common/anjian/law/recordContent.vue
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('yt-page',{attrs:{"title":"隐患内容","flex":""}},[_c('yt-form',[_c('yt-card',{attrs:{"title":"隐患信息"}},[_c('yt-btn',{staticClass:"btn",attrs:{"slot":"more","disabled":_vm.disabled,"plain":_vm.disabled,"size":"mini"},on:{"click":_vm.doAdd},slot:"more"},[_vm._v("添加")]),_vm._v(" "),_c('yt-textarea',{attrs:{"placeholder":"请输入隐患内容...","type":"row","title":"隐患内容"},model:{value:(_vm.form.desc),callback:function ($$v) {_vm.$set(_vm.form, "desc", $$v)},expression:"form.desc"}}),_vm._v(" "),_c('yt-cell',{attrs:{"label":"扣分","border":"none"}},[_c('yt-input',{attrs:{"placeholder":"请输入分值...","clearable":false},model:{value:(_vm.form.score),callback:function ($$v) {_vm.$set(_vm.form, "score", $$v)},expression:"form.score"}})],1)],1)],1),_vm._v(" "),_c('yt-shopCart',{ref:"cart"},[_c('div',{staticClass:"icon",class:_vm.getClass,style:(("background-image: url(" + _vm.url + ")")),on:{"click":_vm.doShow,"animationend":function($event){if($event.target !== $event.currentTarget){ return null; }return _vm.doEnd($event)},"mozAnimationend":function($event){if($event.target !== $event.currentTarget){ return null; }return _vm.doEnd($event)},"msAnimationend":function($event){if($event.target !== $event.currentTarget){ return null; }return _vm.doEnd($event)},"oAnimationend":function($event){if($event.target !== $event.currentTarget){ return null; }return _vm.doEnd($event)},"webkitAnimationend":function($event){if($event.target !== $event.currentTarget){ return null; }return _vm.doEnd($event)}}},[(_vm.list.length)?_c('yt-badge',{staticClass:"badge",class:{'badge-scale': _vm.play},attrs:{"value":_vm.list.length}}):_vm._e()],1),_vm._v(" "),_c('div',{staticClass:"info"},[_c('div',{staticClass:"logo-content"},[_c('div',{staticClass:"logo-desc"},[_vm._v("\n          共添加"),_c('span',{staticClass:"logo-num",class:{'is-highlight': _vm.list.length}},[_vm._v(_vm._s(_vm.list.length))]),_vm._v("条隐患记录\n        ")]),_vm._v(" "),_c('yt-btn',{staticClass:"logo-btn",class:_vm.list.length ? 'enough' : 'not-enough',attrs:{"loading":_vm.onSave,"edge":""}},[_vm._v("确定")])],1)])]),_vm._v(" "),_c('yt-popup',{attrs:{"slot":"alert"},slot:"alert",model:{value:(_vm.show),callback:function ($$v) {_vm.show=$$v},expression:"show"}},[_c('div',{staticClass:"select"},[_c('yt-sticky',{staticClass:"select-title",attrs:{"top":"0px"}},[_c('div',[_vm._v("\n          以下为已添加内容\n          "),_c('span',{staticClass:"select-title-btn",on:{"click":_vm.onClear}},[_c('i',{staticClass:"yt-icon yt-icon-clear"}),_vm._v("清空")])])]),_vm._v(" "),_c('ul',_vm._l((_vm.list),function(item,index){return _c('li',{key:index,staticClass:"select-row"},[_vm._v("\n          "+_vm._s(index + 1)+"："+_vm._s(item.desc)+"\n          "),_c('i',{staticClass:"select-row-icon yt-icon yt-icon-reduce",on:{"click":function($event){return _vm.onRemove(index)}}})])}),0)],1)])],1)}
var staticRenderFns = []
var esExports = { render: render, staticRenderFns: staticRenderFns }
/* harmony default export */ var law_recordContent = (esExports);
// CONCATENATED MODULE: ./src/common/anjian/law/recordContent.vue
function injectStyle (ssrContext) {
  __webpack_require__("H7Q2")
}
var normalizeComponent = __webpack_require__("C7Lr")
/* script */


/* template */

/* template functional */
var __vue_template_functional__ = false
/* styles */
var __vue_styles__ = injectStyle
/* scopeId */
var __vue_scopeId__ = "data-v-2fe958fe"
/* moduleIdentifier (server only) */
var __vue_module_identifier__ = null
var Component = normalizeComponent(
  recordContent,
  law_recordContent,
  __vue_template_functional__,
  __vue_styles__,
  __vue_scopeId__,
  __vue_module_identifier__
)

/* harmony default export */ var anjian_law_recordContent = __webpack_exports__["default"] = (Component.exports);


/***/ })

});